<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    注册
    账号 <input type="text" id="user"><br>
    密码 <input type="text" id="pass"><br>
    <button class="but"> 登录</button>
</body>

</html>
<script src="./ObjectAjax.js"></script>
<script>
    let ajax = new PublicUser()

    class Login {
        constructor({ $, get, post }) {
            this.$ = $
            this.get = get
            this.post = post
            this.loginGet()//入口文件
        }
        loginGet() {
            let thas = this
            this.$(".but").addEventListener("click", e => {
                if (e.target.className === "but") {
                  
                    thas.get({
                        url: "/login",
                        text: {
                            user: thas.$("#user").value,
                            pass: thas.$("#pass").value
                        },
                        callback(str) {
                    
                            if (str === "001") {
                                location.href = "http://localhost:3000/hom.html"
                            }

                        }
                    })
                }

            })
        }


    }
    new Login(ajax)
</script>